<?php
/**************************** SERVICE INITIALIZATION BEGINS ****************************/
require_once("../../config.php");
require_once(ML_ROOT."/service-admin.php"); on_models_edit();

$model = isset($view_data[Protocol::MODEL]) ? $view_data[Protocol::MODEL] : NULL;
$photo_list = isset($view_data[Protocol::PHOTO_LIST]) ? $view_data[Protocol::PHOTO_LIST] : NULL;
/***************************** SERVICE INITIALIZATION ENDS *****************************/
?>

<?php
/********************************* HTML CONTENT BEGINS *********************************/
require_once(ML_INCLUDE."/admin-header.php");
?>
	<h1>Model Edit</h1>
	<form action="<?=url("/admin/models-edit.php")?>" method="post" autocomplete="on">
	<table>
		<?php if (isset($model[Protocol::ID])) :?>
		<tr>
			<td><label for="id">id</label></td>
			<td><input name="<?=Protocol::ID?>" id="id" type="text" value="<?=$model[Protocol::ID]?>" readonly /></td>
		</tr>
		<?php endif ?>
		<?php if (isset($model[Protocol::USER_ID])) :?>
		<tr>
			<td><label for="user_id">user_id</label></td>
			<td><input name="<?=Protocol::USER_ID?>" id="user_id" type="text" value="<?=$model[Protocol::USER_ID]?>" readonly /></td>
		</tr>
		<?php endif ?>
		<tr>
			<td><label for="email">email</label></td>
			<?php if (isset($model[Protocol::EMAIL])) :?>
			<td><input name="<?=Protocol::EMAIL?>" id="email" type="email" value="<?=$model[Protocol::EMAIL]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::EMAIL?>" id="email" type="email" autofocus /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="password">password</label></td>
			<?php if (isset($model[Protocol::PASSWORD])) :?>
			<td><input name="<?=Protocol::PASSWORD?>" id="password" type="password" value="<?=$model[Protocol::PASSWORD]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::PASSWORD?>" id="password" type="password" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="conrimation">confirmation</label></td>
			<td><input name="conrimation" id="conrimation" type="password" /></td>
		</tr>
		<tr>
			<td><label for="name">name</label></td>
			<?php if (isset($model[Protocol::NAME])) :?>
			<td><input name="<?=Protocol::NAME?>" id="name" type="text" value="<?=$model[Protocol::NAME]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::NAME?>" id="name" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="description">description</label></td>
			<?php if (isset($model[Protocol::DESCRIPTION])) :?>
			<td><textarea name="<?=Protocol::DESCRIPTION?>" id="description"><?=$model[Protocol::DESCRIPTION]?></textarea></td>
			<?php else :?>
			<td><textarea name="<?=Protocol::DESCRIPTION?>" id="description"></textarea></td>
			<?php endif ?>
		</tr>
		<?php if (isset($model[Protocol::VIEWS])) :?>
		<tr>
			<td><label for="views">views</label></td>
			<td><input name="<?=Protocol::VIEWS?>" id="views" type="number" value="<?=$model[Protocol::VIEWS]?>" /></td>
		</tr>
		<?php endif ?>
		<?php if (isset($model[Protocol::LIKES])) :?>
		<tr>
			<td><label for="likes">likes</label></td>
			<td><input name="<?=Protocol::LIKES?>" id="likes" type="number" value="<?=$model[Protocol::LIKES]?>" /></td>
		</tr>
		<?php endif ?>
		<tr><td><h2>Model Profile</h2></td></tr>
		<tr>
			<td><label for="birth">birth</label></td>
			<?php if (isset($model[Protocol::BIRTH])) :?>
			<td><input name="<?=Protocol::BIRTH?>" id="birth" type="text" value="<?=$model[Protocol::BIRTH]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::BIRTH?>" id="birth" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="gender">gender</label></td>
			<?php if (isset($model[Protocol::GENDER])) :?>
			<td><input name="<?=Protocol::GENDER?>" id="gender" type="text" value="<?=$model[Protocol::GENDER]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::GENDER?>" id="gender" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="height">height</label></td>
			<?php if (isset($model[Protocol::HEIGHT])) :?>
			<td><input name="<?=Protocol::HEIGHT?>" id="height" type="number" value="<?=$model[Protocol::HEIGHT]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::HEIGHT?>" id="height" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="weight">weight</label></td>
			<?php if (isset($model[Protocol::WEIGHT])) :?>
			<td><input name="<?=Protocol::WEIGHT?>" id="weight" type="number" value="<?=$model[Protocol::WEIGHT]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::WEIGHT?>" id="weight" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="chest">chest</label></td>
			<?php if (isset($model[Protocol::CHEST])) :?>
			<td><input name="<?=Protocol::CHEST?>" id="chest" type="number" value="<?=$model[Protocol::CHEST]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::CHEST?>" id="chest" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="waist">waist</label></td>
			<?php if (isset($model[Protocol::WAIST])) :?>
			<td><input name="<?=Protocol::WAIST?>" id="waist" type="number" value="<?=$model[Protocol::WAIST]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::WAIST?>" id="waist" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="hips">hips</label></td>
			<?php if (isset($model[Protocol::HIPS])) :?>
			<td><input name="<?=Protocol::HIPS?>" id="hips" type="number" value="<?=$model[Protocol::HIPS]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::HIPS?>" id="hips" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="shoe">shoe</label></td>
			<?php if (isset($model[Protocol::SHOE])) :?>
			<td><input name="<?=Protocol::SHOE?>" id="shoe" type="number" value="<?=$model[Protocol::SHOE]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::SHOE?>" id="shoe" type="number" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="educations">educations</label></td>
			<?php if (isset($model[Protocol::EDUCATIONS])) :?>
			<td><input name="<?=Protocol::EDUCATIONS?>" id="educations" type="text" value="<?=$model[Protocol::EDUCATIONS]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::EDUCATIONS?>" id="educations" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="agencies">agencies</label></td>
			<?php if (isset($model[Protocol::AGENCIES])) :?>
			<td><input name="<?=Protocol::AGENCIES?>" id="agencies" type="text" value="<?=$model[Protocol::AGENCIES]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::AGENCIES?>" id="agencies" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="locations">locations</label></td>
			<?php if (isset($model[Protocol::LOCATIONS])) :?>
			<td><input name="<?=Protocol::LOCATIONS?>" id="locations" type="text" value="<?=$model[Protocol::LOCATIONS]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::LOCATIONS?>" id="locations" type="text" /></td>
			<?php endif ?>
		</tr>
		<tr>
			<td><label for="tags">tags</label></td>
			<?php if (isset($model[Protocol::TAGS])) :?>
			<td><input name="<?=Protocol::TAGS?>" id="tags" type="text" value="<?=$model[Protocol::TAGS]?>" /></td>
			<?php else :?>
			<td><input name="<?=Protocol::TAGS?>" id="tags" type="text" /></td>
			<?php endif ?>
		</tr>
		<?php if(isset($photo_list)) :?>
		<tr>
			<td>main_photo</td>
			<td colspan="2">
			<?php if (count($photo_list) > 0) :?>
			<?php foreach ($photo_list as $photo) :?>
				<?php if ($photo[Protocol::ID] == $model[Protocol::MAIN_PHOTO_ID]) :?>
				<input type="radio" name="<?=Protocol::MAIN_PHOTO_ID?>" value="<?=$photo[Protocol::ID]?>" checked="true" />
				<?php else :?>
				<input type="radio" name="<?=Protocol::MAIN_PHOTO_ID?>" value="<?=$photo[Protocol::ID]?>" />
				<?php endif ?>
				<img src="<?=media($photo[Protocol::THUMB_S])?>" />
			<?php endforeach ?>
			<?php else :?>
				<span>No Photos</span>
			<?php endif ?>
			</td>
		</tr>
		<?php endif ?>
		<tr>
			<td colspan="2"><button type="submit">Confirm</button></td>
		</tr>
	</table>
	</form>
<?php
require_once(ML_INCLUDE."/admin-footer.php");
/********************************** HTML CONTENT ENDS **********************************/
?>